const mongoose = require('mongoose');

// 定义Todo模型的架构
const todoSchema = new mongoose.Schema({
    value: {
        type: String,
        required: [true, '待办事项内容不能为空'],
        trim: true
    },
    isCompleted: {
        type: Boolean,
        default: false
    },
    createdAt: {
        type: Date,
        default: Date.now
    }
});

// 创建并导出Todo模型
module.exports = mongoose.model('Todo', todoSchema, 'list'); 